/**
 * Created by henian.xu on 2019/2/26.
 *
 */

const path = require('path');
const webpack = require('webpack');

function resolve(dir) {
  return path.join(__dirname, '.', dir);
}

module.exports = {
  resolve: {
    alias: {
      '@': resolve('src'),
      pages: resolve('src/pages'),
      views: resolve('src/views'),
      api: resolve('src/api'),
      mock: resolve('src/mock'),
      assets: resolve('src/assets'),
      components: resolve('src/components'),
      packages: resolve('src/packages'),
      mixins: resolve('src/mixins'),
      config: resolve('src/config'),
      router: resolve('src/router'),
      store: resolve('src/store'),
      utils: resolve('src/utils'),
    },
  },
  plugins: [
    new webpack.ContextReplacementPlugin(
      // 需要被处理的文件目录位置
      /moment[/\\]locale/,
      // 正则匹配需要被包括进来的文件
      /(en|zh-cn)\.js/,
    ),
  ],
  externals: {
    globalVar: 'window.__GLOBAL_VAR__||{}',
    jweixin: 'window.wx',
  },
};
